﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BusinessClasses;
using Common;
using NewsIndia.AuthFilters;
using NewsIndiaBAL;
using Newtonsoft.Json;

namespace NewsIndia.Controllers
{
    [UserAuth]
    [AdminAuth]
    public class UserController : Controller
    {

        //public ActionResult Index()
        //{
        //    return View();
        //}

        public ActionResult AddUser()
        {
            var userModel = new UserModel();
            // var countriesList = new List<CountryMaster>();
            var countryList = CountryList.GetCountryList();
            //   var statesList = new List<StateMaster>();
            var stateList = StateList.GetStateList();
            if (countryList.Any())
            {
                if (countryList.Count > 0)
                {
                    // countriesList.RemoveAt(countriesList.Count - 1);
                    userModel.DropDownForCountry =
                        countryList.Select(c => new SerializableSelectListItem
                        {
                            Text = c.CountryName,
                            Value = c.CountryId.ToString(CultureInfo.InvariantCulture)
                        });
                }
            }

            if (stateList.Any())
            {
                if (stateList.Count > 0)
                {
                    //  statesList.RemoveAt(statesList.Count - 1);
                    userModel.DropDownForState =
                        stateList.Select(c => new SerializableSelectListItem
                        {
                            Text = c.StateName,
                            Value = c.StateId.ToString(CultureInfo.InvariantCulture)
                        });
                }
            }

            return View(userModel);
        }
    }
}